// vite.config.ts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import monaco from "vite-plugin-monaco-editor";

export default defineConfig({
  plugins: [react(), monaco({})],
  resolve: { alias: { "@": "/src" } }, // 路径别名
  server: {
    proxy: {
      // 代理规则：所有以 /api 开头的请求
      "/api": {
        target: "http://192.168.1.189:20201", // 后端服务地址
        changeOrigin: true, // 修改请求头 Origin 为目标地址
        rewrite: (path) => path.replace(/^\/api/, ""),
        bypass: (req) => {
          debugger;
        },
      },
      "/api2": {
        target: "http://192.168.1.235/", // 后端服务地址
        changeOrigin: true, // 修改请求头 Origin 为目标地址
        rewrite: (path) => path.replace(/^\/api2/, ""),
        bypass: (req) => {
          debugger;
        },
      },
    },
    host: "0.0.0.0",
  },
});
